// components/footer/footer.js
var cf = require("../../config.js");
const app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    selected_menu: {
      type: String,
      value: ""
    },
    unread_msg_total_num: {
      type: Number,
      value: 0
    },
    x_style: {
      type: String,
      value: app.globalData.xStyle || ''
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    staticResPath: cf.config.posterOssHost,
    userImagePath: cf.config.userImagePath
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onBottomNav(e) {
      var that = this;
      let employee = wx.getStorageSync('employee')
      var { url, type } = e.currentTarget.dataset;
      if(url=='/pages/sales/msglist/msglist'){
          app.subscribeMessage(()=>{
            wx.redirectTo({
              url: url,
            })
          },cf.config.messageTemplateId)
      }else{
        wx.redirectTo({
          url: url,
        })
      }
     
      if (type) {
        //收集点击名片海报信息
        app.globalData.sensors.track(type, {
          account_id: wx.getStorageSync('userId'),
          role: employee ? '置业顾问' : '用户'
        });
      }
    },
    handleCommonFormSubmit(e) {
      let formId = e.detail.formId;
      let cusmallToken = wx.getStorageSync('cusmallToken');
      wx.request({
        url: cf.config.pageDomain + '/applet/mobile/addFormId',
        data: {
          cusmallToken: cusmallToken,
          formId: formId
        },
        header: {
          'content-type': 'application/json'
        },
        success: function (res) {
          console.log("addFormId success：", formId);
        }
      })
    }
  }
})
